package com.ruoyi.fpa.service.impl;

import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.system.util.SnowFlakeUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.fpa.mapper.GenReferenceColumnMapper;
import com.ruoyi.fpa.domain.GenReferenceColumn;
import com.ruoyi.fpa.service.IGenReferenceColumnService;

/**
 * 外键关联Service业务层处理
 *
 * @author koradji@116.com
 * @date 2023-09-17
 */
@Service
public class GenReferenceColumnServiceImpl implements IGenReferenceColumnService
{
    @Autowired
    private GenReferenceColumnMapper genReferenceColumnMapper;

    /**
     * 查询外键关联
     *
     * @param referenceColumnId 外键关联主键
     * @return 外键关联
     */
    @Override
    public GenReferenceColumn selectGenReferenceColumnByReferenceColumnId(Long referenceColumnId)
    {
        return genReferenceColumnMapper.selectGenReferenceColumnByReferenceColumnId(referenceColumnId);
    }

    /**
     * 查询外键关联列表
     *
     * @param genReferenceColumn 外键关联
     * @return 外键关联
     */
    @Override
    public List<GenReferenceColumn> selectGenReferenceColumnList(GenReferenceColumn genReferenceColumn)
    {
        return genReferenceColumnMapper.selectGenReferenceColumnList(genReferenceColumn);
    }

    /**
     * 新增外键关联
     *
     * @param genReferenceColumn 外键关联
     * @return 结果
     */
    @Override
    public int insertGenReferenceColumn(GenReferenceColumn genReferenceColumn)
    {
        genReferenceColumn.setCreateTime(DateUtils.getNowDate());
        if(StringUtils.isEmpty(String.valueOf(genReferenceColumn.getReferenceColumnId()))) {
            genReferenceColumn.setReferenceColumnId(SnowFlakeUtils.snowFlakeId());
        }
        return genReferenceColumnMapper.insertGenReferenceColumn(genReferenceColumn);
    }

    /**
     * 修改外键关联
     *
     * @param genReferenceColumn 外键关联
     * @return 结果
     */
    @Override
    public int updateGenReferenceColumn(GenReferenceColumn genReferenceColumn)
    {
        genReferenceColumn.setUpdateTime(DateUtils.getNowDate());
        return genReferenceColumnMapper.updateGenReferenceColumn(genReferenceColumn);
    }

    /**
     * 批量删除外键关联
     *
     * @param referenceColumnIds 需要删除的外键关联主键
     * @return 结果
     */
    @Override
    public int deleteGenReferenceColumnByReferenceColumnIds(Long[] referenceColumnIds)
    {
        return genReferenceColumnMapper.deleteGenReferenceColumnByReferenceColumnIds(referenceColumnIds);
    }

    /**
     * 删除外键关联信息
     *
     * @param referenceColumnId 外键关联主键
     * @return 结果
     */
    @Override
    public int deleteGenReferenceColumnByReferenceColumnId(Long referenceColumnId)
    {
        return genReferenceColumnMapper.deleteGenReferenceColumnByReferenceColumnId(referenceColumnId);
    }
}
